package com.hxzy;

import com.hxzy.util.TokenDecode;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

import java.util.Map;

public class TestToken {
    public static void main(String[] args) {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5OTI5NzFlYi1lMDNjLTQ1MjgtOWYwYi1lZTQ0NzU5ODQwODIiLCJzdWIiOiJjY2MiLCJpc3MiOiJhZG1pbiIsImlhdCI6MTYzNTk1MzI1NiwiZXhwIjoxNjM1OTU2ODU2fQ.3k8HeCT-hYNYfxYlf6e8gbHs3dCf9bHqy7nsk_N6af8";
        Claims claims= Jwts.parser().setSigningKey("itcast").parseClaimsJws(token).getBody();
        System.out.println(claims);

         Map<String, String> userInfo = TokenDecode.getUserInfo(token);
        String username = userInfo.get("sub");
        System.out.println(username);

    }
}
